#!/usr/bin/env python
# coding=utf-8

# File Name: mongodb.py
# Author: Bill Zhang
# Mail: zchcandid@gmail.com 
# Created Time: Tue 26 Nov 2013 10:25:33 AM CST
import time
import pymongo

class ManMongo:
    """this is the encapsulation of  pymongo!
    """

    def __init__(self,uri):
        self.uri=uri
        try:
            self.con=pymongo.MongoClient(self.uri)
        except pymongo.errors.ConnectionFailure:
            print("fail to connect mongodb,try after 3s")
            time.sleep(3)
            self.con=pymongo.MongoClient(self.uri)
        except pymongo.errors.InvalidURI:
            print("Your uri is not write,fail to connect mongodb!")
            print("The formate should be 'mongodb://user:password@example.com/the_database'")
            print("Please try again!")
 
        
    def insert(self,collection,data):
    #insert the data into the mongodb 
    #the collections's name
        try:
            self.con.collection
